<?php include "menu.phtml"; ?>
<div id="right">
	<div class="rightbox">
		<h1><?php echo $this->name; ?></h1>
		<br />
		<?php if($this->owner == $this->auth->getIdentity()->id): ?>
			<?php if($this->featured): ?>
				<?php if($this->featured_bermuda_triangle): ?>
					<div class="c_success"><ul><li><?php echo sprintf($this->translate->_("This chat channel will be featured on Petolio's homepage %s"), $this->featured_bermuda_triangle); ?></li></ul></div>
				<?php else: ?>
					<div class="c_success"><ul><li><?php echo $this->translate->_("This chat channel is featured on Petolio's homepage"); ?></li></ul></div>
				<?php endif; ?>
			<?php else: ?>
				<div class="c_error"><ul><li><?php echo sprintf($this->translate->_("This chat channel is not featured on Petolio's homepage. <a href='%s'>Click here feature it</a>"), $this->url(array('controller'=>'chat', 'action'=>'feature', 'id' => $this->id), 'default', true)); ?></li></ul></div>
			<?php endif; ?>
			<br />
		<?php endif; ?>
		<div id="chat"></div>
	</div>
</div>
<script type="text/javaScript" src="<?php echo Petolio_Service_Util::autoVersion('/js/chat/chat.js'); ?>"></script>
<script type="text/javaScript">
	// Add Session.js to APE JSF to handle multitab and page refresh
	APE.Config.scripts.push(APE.Config.baseUrl + '/Source/Core/Session.js');

	// Initialize APE_Client
	READY(function() {
		new Chat({
			container: $('chat'),
			channelId: '<?php echo $this->id; ?>',
			owner: '<?php echo $this->owner; ?>',
			name: '<?php echo $this->auth->getIdentity()->id; ?>',
			translate: [
				'<?php echo $this->translate->_("Please refresh this page if the chat application did not load."); ?>',
				'<?php echo $this->translate->_("You are already in this channel with another browser."); ?>',
				'<?php echo $this->translate->_("Unknown"); ?>',
				'<?php echo $this->translate->_("Loading profile..."); ?>',
				'<?php echo $this->translate->_("Type a message here..."); ?>',
				'<?php echo $this->translate->_("Emoticons"); ?>',
				'<?php echo $this->translate->_("has joined the channel."); ?>',
				'<?php echo $this->translate->_("has left the channel."); ?>',
				'<?php echo $this->translate->_("Show messages from:"); ?>',
				'<?php echo $this->translate->_("Yesterday"); ?>',
				'<?php echo $this->translate->_("7 days"); ?>',
				'<?php echo $this->translate->_("30 days"); ?>',
				'<?php echo $this->translate->_("3 months"); ?>',
				'<?php echo $this->translate->_("New chat message!"); ?>',
				'<?php echo $this->translate->_("Kick"); ?>',
				'<?php echo $this->translate->_("Are you sure you want to kick %s?"); ?>',
				'<?php echo $this->translate->_("User cannot be kicked"); ?>',
				'<?php echo $this->translate->_("You have been kicked from this channel"); ?>'
			]
		}).load({
			identifier: '<?php echo $this->id; ?>',
			channel: '<?php echo $this->id; ?>'
		});
	});
</script>